package com.vecspace.jsmodel;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;

public class LayuiPlugin {
	/**
	 * 将List组装成JS Layui table Plugin适用的格式
	 */
	public HashMap<String, Object> getGridData(Collection<?> data, int totalRowsCount){
		if(data == null) {
			data= new ArrayList<>();
		}
		HashMap<String, Object> map = new HashMap<>();
		map.put("code", 0);
		map.put("msg", "");
		map.put("data", data);
		if(totalRowsCount <= 0) {
			totalRowsCount = data.size();
		}
		map.put("count", totalRowsCount);
		return map;
	}
}
